package com.wdh.kjs.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wdh.kjs.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by cqh on 2016/4/20.
 */

public class InvestmentRecordAdapter extends BaseAdapter {

    private List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
    private Context context;
    private HashMap<String, String> maps = new HashMap<String, String>();

    public InvestmentRecordAdapter(Context context, List<HashMap<String, String>> data) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;

        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.list_of_investmentrecord, null);
            viewHolder.im_investment_type = (TextView) convertView.findViewById(R.id.im_investment_type);
            viewHolder.im_investment_name = (TextView) convertView.findViewById(R.id.im_investment_name);
            viewHolder.im_investment_scale = (TextView) convertView.findViewById(R.id.im_investment_scale);
            viewHolder.im_investment_month = (TextView) convertView.findViewById(R.id.im_investment_month);
            viewHolder.im_investment_money = (TextView) convertView.findViewById(R.id.im_investment_money);
            viewHolder.im_investment_state = (TextView) convertView.findViewById(R.id.im_investment_state);
            viewHolder.im_investment_time = (TextView) convertView.findViewById(R.id.im_investment_time);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        maps = data.get(position);

        viewHolder.im_investment_type.setText(maps.get("im_investment_type"));
        viewHolder.im_investment_name.setText(maps.get("im_investment_name"));
        viewHolder.im_investment_scale.setText(maps.get("im_investment_scale"));
        viewHolder.im_investment_month.setText(maps.get("im_investment_month"));
        viewHolder.im_investment_money.setText(maps.get("im_investment_money"));
        viewHolder.im_investment_state.setText(maps.get("im_investment_state"));
        viewHolder.im_investment_time.setText(maps.get("im_investment_time"));


        return convertView;
    }

    class ViewHolder {
        TextView im_investment_type;
        TextView im_investment_name;
        TextView im_investment_scale;
        TextView im_investment_month;
        TextView im_investment_money;
        TextView im_investment_state;
        TextView im_investment_time;

    }
}